﻿@model IEnumerable<MMSWebsite.Models.Group>

@{
    ViewBag.Title = "Group Index";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}

<h1>Group Index</h1>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.GroupName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Area)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Responsibility)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.GroupName)
            </td>
            <td>
                @if (item.Area.City != null)
                {
                    <b>Thành Phố @item.Area.City</b>
                    int i = 1;
                    foreach (var district in item.Area.Districts)
                    {
                        if(i == 1) 
                        { 
                            @: : 
                        }
                        else
                        {
                            @:, 
                        }
                        @district
                        i++;
                    }
                }
            
            </td>
            <td>
                @if (item.Responsibility != null)
                {
                    <a href="@Url.Action("Edit", "Employee", new {id = item.Responsibility.Employee.Id})" style="font-size: 20px; color: darkcyan; font-weight: bold; font-family: Time New Roman">@item.Responsibility.Employee.Name</a>
                }
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
                @Html.ActionLink("Details", "Details", new { id = item.Id })
            </td>
        </tr>
    }

</table>
<div style="text-align: center">
    <input type="button" value="Create New" onclick="location.href = '@Url.Action("Create", "Group")'" />
</div>
